// i.d(t, { B: () => PinsViewData })
import pinStateEnum from "../enum/pinState.enum"
import Data from "../object/Data"
import ObservableValue, { createObVal } from "../observer/observable.value"

export default class PinsViewData extends Data {
  creatingPin: boolean
  pinStateObservable: ObservableValue<string>
  openPinObservable: ObservableValue<any>
  editableObservable: ObservableValue<boolean>
  previewPinObservable: ObservableValue<any>
  progressObservable: ObservableValue<number>
  screenPositionObservable: ObservableValue<THREE.Vector2>
  canPlaceObservable: ObservableValue<boolean>
  canAddObservable: ObservableValue<boolean>
  constructor() {
    super()
    this.name = "pins-view-data"
    this.creatingPin = !1
    this.pinStateObservable = createObVal(pinStateEnum.IDLE)
    this.openPinObservable = createObVal(null)
    this.editableObservable = createObVal<boolean>(true)
    this.previewPinObservable = createObVal(null)
    this.progressObservable = createObVal(-1)
    this.screenPositionObservable = createObVal(null)
    this.canPlaceObservable = createObVal<boolean>(true)
    this.canAddObservable = createObVal<boolean>(true)
  }
  get creatingNewPin() {
    return this.creatingPin
  }
  updateOpenPin(e) {
    const t = this.openPin
    if (t) {
      const i = Object.assign(Object.assign({}, t), e)
      this.setOpenPin(i)
    }
  }
  setOpenPin(e) {
    this.openPinObservable.value = e
  }
  get openPin() {
    return this.openPinObservable.value
  }
  onOpenPinChanged(e) {
    return this.openPinObservable.onChanged(e)
  }
  setPreviewPin(e) {
    this.previewPinObservable.value = e
  }
  get previewPin() {
    return this.previewPinObservable.value
  }
  onPreviewPinChanged(e) {
    return this.previewPinObservable.onChanged(e)
  }
  setPinState(e) {
    switch (e) {
      case pinStateEnum.IDLE:
      case pinStateEnum.OPEN:
      case pinStateEnum.PREVIEWING:
        this.creatingPin = !1
        break
      case pinStateEnum.CREATING:
        this.creatingPin = !0
    }
    this.pinStateObservable.value = e
  }
  get pinState() {
    return this.pinStateObservable.value
  }
  onPinStateChanged(e) {
    return this.pinStateObservable.onChanged(e)
  }
  setProgress(e) {
    this.progressObservable.value = e
  }
  get progress() {
    return this.progressObservable.value
  }
  onProgressChanged(e) {
    const t = this.progressObservable.onChanged(e)
    return t.renew(), t
  }
  get screenPosition() {
    return this.screenPositionObservable.value
  }
  setScreenPosition(e) {
    this.screenPositionObservable.value = e
  }
  onScreenPositionChanged(e) {
    return this.screenPositionObservable.onChanged(e)
  }
  get isPinEditable() {
    return this.editableObservable.value
  }
  setEditablePin(e) {
    this.editableObservable.value = e
  }
  get canAdd() {
    return this.canAddObservable.value
  }
  setCanAdd(e) {
    this.canAddObservable.value = e
  }
  onCanAddChanged(e) {
    return this.canAddObservable.onChanged(e)
  }
  get canPlace() {
    return this.canPlaceObservable.value
  }
  setCanPlace(e: boolean) {
    this.canPlaceObservable.value = e
  }
  onCanPlaceChanged(e) {
    return this.canPlaceObservable.onChanged(e)
  }
}
